package com.cx.thread;

import java.util.concurrent.Callable;

public class MyCallable1 implements Callable<Integer> {// (1)实现Callable接口
    private Integer n;
    public MyCallable1(int n){
        this.n = n;
    }
    // (2)重写cal方法，封装逻辑并返回结果
    @Override
    public Integer call() throws Exception {
        System.out.println("任务 " + n + " 正在执行，线程：" + Thread.currentThread().getName());
        Thread.sleep(1000); // 模拟任务执行时间
        return n;

    }
}